package com.itheima.day09泛型和二叉树.练习;

import sun.reflect.generics.tree.Tree;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.TreeSet;

/*有一串没有任何规律的字符串"kjsdneosjsakewoiqercnjnvz923nj4339ufd",
现需要将字符串中重复的字符去掉，并且
进行自然排序后得到新的字符串，最后输出新的字符串。*/
public class Demo1 {
    public static void main(String[] args) {
        TreeSet<String> set=new TreeSet<String>((String c1, String c2) -> {
            return c1.compareTo(c2); });
        String str = "kjsdneosjsakewoiqercnjnvz923nj4339ufd";
        String[] ss=str.split("");
        String s = Arrays.toString(ss);
        System.out.println(s);
        Collections.addAll(set,ss);
        //Arrays.toString(set.toArray(new String[set.size()]));
        System.out.println(Arrays.toString(set.toArray(new String[set.size()])));
        //ArrayList 底层是数组实现,LinkedList底层是链表实现 ,TreeSet底层是红黑树实现(左旋右旋)

    }
}
